﻿using SpaceNeedle.x6473.WindowsPhone.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SpaceNeedle.x6473.WindowsPhone.Models
{
    public class RequestItem
    {
        public System.Guid Id { get; set; }
        public string Address { get; set; }
        public string Geoposition { get; set; }
        public string Description { get; set; }
        public string CreatedBy { get; set; }
        public string CreatedByName { get; set; }
        public System.DateTime CreationDate { get; set; }
        public int Status { get; set; }
        public Nullable<System.DateTime> UpdateDate { get; set; }
        public string UpdatedBy { get; set; }
        public System.Guid RequestId { get; set; }
        public string Photo { get; set; }
        public string RequestTitle
        {
             get 
            {
                var request = AppViewModel.Instance.GetRequestById(this.RequestId);

                 if(request == null)
                 {
                     return null;
                 }

                 return request.Title;
            }
        }
        public string RequestDescription
        {
            get
            {
                var request = AppViewModel.Instance.GetRequestById(this.RequestId);

                if (request == null)
                {
                    return null;
                }

                return request.Description;
            }
        }

        public string RequestIcon
        {
            get
            {
                var request = AppViewModel.Instance.GetRequestById(this.RequestId);

                if (request == null)
                {
                    return null;
                }

                return request.Icon;
            }
        }

        public int TotalSupportersCount
        {
            get
            {
                return this.SupportersCount + 1;
            }
        }

        public string UserTypedAddress { get; set; }
        public int SupportersCount { get; set; }
        public string Permalink { get; set; }
        public string Base64Photo { get; set; }
        public string Number { get; set; }
    }
}
